package com.ruoyi.jim.processor;

import org.jim.core.ImChannelContext;
import org.jim.core.ImPacket;
import org.jim.core.exception.ImException;
import org.jim.server.processor.handshake.WsHandshakeProcessor;

public class JIMWsHandshakeProcessor extends WsHandshakeProcessor {

    @Override
    public void onAfterHandshake(ImPacket packet, ImChannelContext imChannelContext) throws ImException {
//        LoginReqHandler loginHandler = (LoginReqHandler) CommandManager.getCommand(Command.COMMAND_LOGIN_REQ);
//        HttpRequest request = (HttpRequest)packet;
//        String username = request.getParams().get("username") == null ? null : (String)request.getParams().get("username")[0];
//        String password = request.getParams().get("password") == null ? null : (String)request.getParams().get("password")[0];
//        String token = request.getParams().get("token") == null ? null : (String)request.getParams().get("token")[0];
//        LoginReqBody loginBody = new LoginReqBody(username,password,token);
//        byte[] loginBytes = JsonKit.toJsonBytes(loginBody);
//        request.setBody(loginBytes);
//        try{
//            request.setBodyString(new String(loginBytes, ImConst.CHARSET));
//        }catch (Exception e){
//            throw new ImException(e);
//        }
//        ImPacket loginRespPacket = loginHandler.task(request, imChannelContext);
//        if(loginRespPacket != null){
//            JimServerAPI.send(imChannelContext, loginRespPacket);
//        }
    }
}
